<?php
/**
 * Display Ressource Carrillion
 *
 * A carrillion is a collection of source that you have selected in the search screen
 *
 */

use Doctrine\DBAL\Types\Type;
use Doctrine\DBAL\Connection;
use Hive\Ressource;

use Fox\Html\Carousel\Item;
use Fox\Html\Carousel;

$xview = Xview::instance();
$ressources = array();
$id = $xview->val('carouselid');
if(!empty($id) && isset($_SESSION['carousel'][$id])) {

	$data = json_decode($_SESSION['carousel'][$id],true);
	if(!is_array($data) || count($data) == 0) {
		
	} else {
		$query = Fox\Dao::infos(Ressource::className())->handle()->createQueryBuilder();
		$query->select('t.ressource_id AS id,last_name,first_name,exp.end_date,exp.jobtitle')
				->from('ressources','t')
				->leftJoin('t','ressource_experiences','exp','t.ressource_id = exp.ressource_id')
				->orderBy('end_date','DESC');
		$fragment = new Fox\Dao\SqlFragment('t.ressource_id IN (?) AND t.loekz = ?  '
										,array($data,0),
										array(Connection::PARAM_INT_ARRAY,Type::INTEGER));
		$ressources = $fragment->pushIn($query)->execute()->fetchAll(\PDO::FETCH_ASSOC);
	}

}

$carousel = new Carousel('contactCarousel');
foreach($ressources as $ressource) {
	$id = $ressource['id'];
	if(isset($traitedRessource[$id])) {
		continue;
	}
	$traitedRessource[$id] = true;
	$title = $content = null;
	$content ='<div class="picture-mini">
					<img src="images/profile.jpg" width="50" height="50" >
				</div>
				<div class="mini ui-unselectable">
					<ul class="">
						<li class="fullname ui-unselectable">'.$ressource['first_name']." ".$ressource['last_name'].'</li>
						<li class="function ui-unselectable">Test</li>
					</ul>
				</div>';
	$carousel->add(new Item($id,$content));
}
echo $carousel->render();
?>
<div id="main-container" class="" style="border-top: 1px solid #DDD;width:90%">
</div>